class Topic < ActiveRecord::Base

  belongs_to :category ,:counter_cache => true
  belongs_to :type ,:counter_cache => true
  belongs_to :nature ,:counter_cache => true
  belongs_to :user ,:counter_cache => true
  belongs_to :tag ,:counter_cache => true
  has_many :comments ,:dependent => :destroy, :order => "created_at ASC"
  has_many :attachments ,:dependent => :destroy, :order => "created_at ASC"
  
  
  def self.try_to_trackback(id,time)
    find(:first,
         :conditions => ["id = ? and created_at.to_s() = ?",id,time]
    )
  end
  
end
